package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.entity.ShoppingCart;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShortCarMapper extends BaseMapper<ShoppingCart> {

    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> queryByUserId(Long userId);




    @Update("update shopping_cart set  number = #{number} where setmeal_id = #{setmealId} and user_id = #{userId}")
    void updateNumberBySetmealIdAndUserId(ShoppingCart shoppingCart);

    void updateByDishIdAndDishFlavorAndUserId(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);

    List<ShoppingCart> query(ShoppingCart shoppingCart);
}
